package cn.cvs.service;

import cn.cvs.dao.SupplierMapper;
import cn.cvs.pojo.Supplier;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;

@Transactional
@Service("SupplierServiceImpl")
public class SupplierServiceImpl implements SupplierService {
    @Autowired
    private SupplierMapper supplierMapper;

    @Override
    public List<Supplier> getList(String supName, String supCode) throws Exception {

        return this.supplierMapper.selectList(supName,supCode);
    }

    @Override
    public int getCount(String supName, String supCode) throws Exception {
        return this.supplierMapper.selectCount(supName, supCode);
    }

    @Override
    public int add(Supplier supplier) throws Exception {
        return this.supplierMapper.add(supplier);
    }

    @Override
    public Supplier getById(Integer id) throws Exception {
        return this.supplierMapper.selectById(id);
    }

    @Override
    public boolean update(Supplier supplier) throws Exception {
        boolean flag = false;
        supplier.setUpdatedTime(new Date());
        if (this.supplierMapper.update(supplier) > 0) {
            flag = true;
        }
        return flag;
    }

    @Override
    public int deleteById(Integer id) throws Exception {
        return this.supplierMapper.deleteById(id);
    }

    @Override
    public List<Supplier> getList() throws Exception {
        return this.supplierMapper.selectSimpleList();
    }
    /*



   */
}
